<!DOCTYPE html><html><head>
      <title>2.TestNG&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x6D4B;&#x8BD5;&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;-&#x6570;&#x636E;&#x9A71;&#x52A8;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///c:\Users\Administrator\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.5.3\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      

      
      
      
      
      
      
      

      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <h1 class="mume-header" id="centertestng%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%B5%8B%E8%AF%95%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F-%E6%95%B0%E6%8D%AE%E9%A9%B1%E5%8A%A8%E6%B5%8B%E8%AF%95center"><center>TestNG&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x6D4B;&#x8BD5;&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;-&#x6570;&#x636E;&#x9A71;&#x52A8;&#x6D4B;&#x8BD5;</center></h1>

<h2 class="mume-header" id="%E4%B8%80-%E6%95%B0%E6%8D%AE%E9%A9%B1%E5%8A%A8%E6%B5%8B%E8%AF%95ddt-%E6%A6%82%E8%A7%88">&#x4E00;&#x3001;&#x6570;&#x636E;&#x9A71;&#x52A8;&#x6D4B;&#x8BD5;(DDT)-&#x6982;&#x89C8;</h2>

<p>&#x4E3B;&#x8981;&#x7528;&#x6765;&#x89E3;&#x51B3;&#x4EE5;&#x4E0B;&#x5F62;&#x5F0F;&#x7684;&#x95EE;&#x9898;:</p>
<ul>
<li>&#x6D4B;&#x8BD5;&#x9700;&#x8981;&#x9488;&#x5BF9;&#x8BB8;&#x591A;&#x5177;&#x6709;&#x7C7B;&#x4F3C;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x7684;&#x6570;&#x636E;&#x6765;&#x6267;&#x884C;</li>
<li>&#x5B9E;&#x9645;&#x7684;&#x6D4B;&#x8BD5;&#x903B;&#x8F91;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4EC5;&#x4EC5;&#x6539;&#x53D8;&#x7684;&#x662F;&#x6570;&#x636E;&#x7ED3;&#x6784;</li>
<li>&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x88AB;&#x4E00;&#x7EC4;&#x4E0D;&#x540C;&#x7684;&#x4EBA;&#x4FEE;&#x6539;</li>
</ul>
<p>&#x5B83;&#x7684;&#x91CD;&#x70B9;&#x4E0D;&#x662F;&#x88AB;&#x6D4B;&#x8BD5;&#x7684;&#x7A0B;&#x5E8F;&#x4EE3;&#x7801;&#x903B;&#x8F91;&#xFF0C;&#x800C;&#x662F;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x6240;&#x60F3;&#x8981;&#x64CD;&#x4F5C;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<p>TestNG&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x901A;&#x8FC7;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x5411;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x53C2;&#x6570;:</p>
<ul>
<li>&#x5229;&#x7528;testng.xml</li>
<li>&#x5229;&#x7528;data providers</li>
</ul>
<h2 class="mume-header" id="%E4%BA%8C-%E5%88%A9%E7%94%A8testngxml%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0">&#x4E8C;&#x3001; &#x5229;&#x7528;testng.xml&#x4F20;&#x9012;&#x53C2;&#x6570;</h2>

<p>&#x53EF;&#x4EE5;&#x5728;testng.xml&#x4E2D;&#x914D;&#x7F6E;&#x9700;&#x8981;&#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x7528;<parameter>&#x6807;&#x7B7E;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;suite&#x4E2D;&#x58F0;&#x660E;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;test&#x4E2D;&#x58F0;&#x660E;&#xFF0C;&#x5982;&#x679C;test&#x4E2D;&#x6709;&#xFF0C;&#x5219;&#x4F18;&#x5148;&#x4F7F;&#x7528;test&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x5219;&#x4F1A;&#x5F80;&#x4E0A;&#x627E;&#x3002;</parameter></p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token doctype">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>suite</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>ddt with Parameters<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>test</span> <span class="token attr-name">thread-count</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>5<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>Test<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parameter</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>name<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>nameInTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parameter</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parameter</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sex<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sexInTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parameter</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>classes</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>class</span>
				<span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.autotest.java.demo.testng.ddt.TestNGDDTDemoTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
				<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>methods</span><span class="token punctuation">&gt;</span></span>
					<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>method</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>validateUserTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>method</span><span class="token punctuation">&gt;</span></span>
				<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>methods</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>class</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>classes</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>test</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>suite</span><span class="token punctuation">&gt;</span></span>
</pre><pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token doctype">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>suite</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>DDT test in suite Parameters<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parameter</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>name<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>nameInSuite<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parameter</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parameter</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sex<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>sexInSuite<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parameter</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>test</span> <span class="token attr-name">thread-count</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>5<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>Test<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>classes</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>class</span>
				<span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.autotest.java.demo.testng.ddt.TestNGDDTDemoTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
				<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>methods</span><span class="token punctuation">&gt;</span></span>
					<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>method</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>validateUserTest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>method</span><span class="token punctuation">&gt;</span></span>
				<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>methods</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>class</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>classes</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>test</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- Test --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>suite</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- Suite --&gt;</span>
</pre><p>&#x5728;&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;&#x4E2D;&#x4F7F;&#x7528;@Parameters&#x6CE8;&#x89E3;&#x6765;&#x83B7;&#x53D6;&#xFF0C;&#x6309;&#x7167;&#x5982;&#x4E0B;&#x65B9;&#x5F0F;&#x4F7F;&#x7528;:</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token annotation punctuation">@Test</span>
<span class="token annotation punctuation">@Parameters</span><span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;sex&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTest</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">boolean</span> result <span class="token operator">=</span> testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;&#x9A8C;&#x8BC1;&#x7ED3;&#x679C;:{}&quot;</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x5982;&#x4E0B;&#x662F;&#x5206;&#x522B;&#x4F7F;&#x7528;&#x8FD9;&#x4E24;&#x4E2A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x8FD0;&#x884C;&#x7684;&#x7ED3;&#x679C;:</p>
<p><img src="./images/testng%E6%A6%82%E8%A7%88/%E4%BC%A0%E9%80%92%E7%9A%84%E5%8F%82%E6%95%B0%E5%AE%9A%E4%B9%89%E5%9C%A8suite%E4%B8%AD.png" alt="&#x5B9A;&#x4E49;&#x5728;suite&#x4E2D;"></p>
<p><img src="./images/testng%E6%A6%82%E8%A7%88/%E4%BC%A0%E9%80%92%E7%9A%84%E5%8F%82%E6%95%B0%E5%AE%9A%E4%B9%89%E5%9C%A8test%E4%B8%AD.png" alt="&#x5B9A;&#x4E49;&#x5728;test&#x4E2D;"></p>
<p>&#x5F53;&#x7136;&#x4E86;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x4E5F;&#x6709;&#x5176;&#x7F3A;&#x70B9;&#xFF0C;&#x5C31;&#x662F;&#x4E0D;&#x652F;&#x6301;&#x975E;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x7684;&#x4F20;&#x9012;&#xFF0C;&#x6216;&#x8005;&#x8BF4;&#x4F60;&#x9700;&#x8981;&#x7684;&#x503C;&#xFF0C;&#x4E0D;&#x80FD;&#x9759;&#x6001;&#x4F20;&#x9012;&#x800C;&#x662F;&#x60F3;&#x8981;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x523B;&#x521B;&#x5EFA;&#xFF0C;&#x5219;&#x53EA;&#x80FD;&#x7528;DataProvider&#x65B9;&#x5F0F;</p>
<h2 class="mume-header" id="%E4%B8%89-%E4%BD%BF%E7%94%A8dataprovider%E6%9D%A5%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0">&#x4E09;&#x3001; &#x4F7F;&#x7528;DataProvider&#x6765;&#x4F20;&#x9012;&#x53C2;&#x6570;</h2>

<h3 class="mume-header" id="31-%E9%80%9A%E7%94%A8%E6%A6%82%E5%BF%B5">3.1 &#x901A;&#x7528;&#x6982;&#x5FF5;</h3>

<p>&#x5B83;&#x53EF;&#x4EE5;&#x7528;@DataProvider&#x6CE8;&#x89E3;&#x6807;&#x6CE8;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x6709;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;name&#x5C5E;&#x6027;&#xFF0C;&#x5B9A;&#x4E49;&#x8FD9;&#x4E2A;&#x63D0;&#x4F9B;&#x8005;&#x7684;&#x540D;&#x79F0;&#x3002;<br>
&#x5982;&#x679C;&#x6CA1;&#x6709;&#x63D0;&#x4F9B;&#x8FD9;&#x4E2A;&#x540D;&#x79F0;&#xFF0C;&#x5219;&#x4F1A;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x7684;&#x540D;&#x79F0;&#x3002;</p>
<p>&#x5B83;&#x901A;&#x5E38;&#x8FD4;&#x56DE;&#x4E00;&#x4E9B;Java&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x5C06;&#x4F1A;&#x4F20;&#x9012;&#x7ED9;&#x67D0;&#x4E2A;&#x88AB;@Test&#x6CE8;&#x89E3;&#x6807;&#x6CE8;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;@Test&#x6CE8;&#x89E3;&#x4E2D;&#x4F7F;&#x7528;dataProvider&#x5C5E;&#x6027;&#x6765;&#x6307;&#x5B9A;&#x3002;</p>
<p>&#x4ECE;&#x672C;&#x8D28;&#x4E0A;&#x8BB2;&#xFF0C;&#x5B83;&#x89E3;&#x51B3;&#x4E86;&#x4E24;&#x4E2A;&#x95EE;&#x9898;:</p>
<ul>
<li>&#x5411;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x4EFB;&#x610F;&#x6570;&#x76EE;&#x7684;&#x53C2;&#x6570;,&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x4F55;&#x7684;Java&#x7C7B;&#x578B;</li>
<li>&#x6839;&#x636E;&#x9700;&#x8981;&#x5141;&#x8BB8;&#x5229;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570;&#x96C6;&#x5408;&#xFF0C;&#x5BF9;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x591A;&#x6B21;&#x6D4B;&#x8BD5;</li>
</ul>
<p>&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x5982;&#x4E0B;:<br>
&#x4E0B;&#x9762;&#x662F;java&#x4EE3;&#x7801;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token comment">/**
 * &#x5E26;&#x53C2;&#x6570;&#x7684;
 */</span>
<span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">validateUser</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token string">&quot;admin&quot;</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token string">&quot;man&quot;</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>sex<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x4E0B;&#x9762;&#x662F;java&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;:</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">Logger</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">LoggerFactory</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">BeforeMethod</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">DataProvider</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">Ignore</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">Test</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">TestNGDDTDemoTestWithDataProvider</span> <span class="token punctuation">{</span>
	<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">Logger</span> LOGGER <span class="token operator">=</span> <span class="token class-name">LoggerFactory</span>
	        <span class="token punctuation">.</span><span class="token function">getLogger</span><span class="token punctuation">(</span><span class="token class-name">TestNGDDTDemoTestWithDataProvider</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token keyword">private</span> <span class="token class-name">TestNGDemo</span> testNGDemo<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@BeforeMethod</span>
	<span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">initInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		testNGDemo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">TestNGDemo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@Test</span>
	<span class="token annotation punctuation">@Ignore</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTest</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
		testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersClearly&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderClearly</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
		testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersUnClearly&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderUnClearly</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;testNGDemo:{}&quot;</span><span class="token punctuation">,</span> testNGDemo<span class="token punctuation">)</span><span class="token punctuation">;</span>
		testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@DataProvider</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;initTestUsersClearly&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">initTestUsersClearly</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;initTestUsersClearly&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
		        <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@DataProvider</span>
	<span class="token keyword">public</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">initTestUsersUnClearly</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;initTestUsersUnClearly&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
		        <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

<span class="token punctuation">}</span>

</pre><p>&#x6D4B;&#x8BD5;&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;:</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersClearly&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin2,sex:women
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:women
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersUnClearly&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] testNGDemo:com.autotest.java.demo.testng.TestNGDemo@166fa74d
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin2,sex:women
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] testNGDemo:com.autotest.java.demo.testng.TestNGDemo@588df31b
[2020.04.29 17:01:48] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:women
[2020.04.29 17:01:48] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] testNGDemo:com.autotest.java.demo.testng.TestNGDemo@7181ae3f
PASSED: validateUserTestWithProviderClearly(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderClearly(&quot;admin2&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderClearly(&quot;admin&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderUnClearly(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderUnClearly(&quot;admin2&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderUnClearly(&quot;admin&quot;, &quot;women&quot;)

===============================================
    Default test
    Tests run: 6, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 6, Passes: 6, Failures: 0, Skips: 0
===============================================

</code></pre><p>&#x4EE5;&#x4E0A;&#x4F8B;&#x5B50;&#x8BC1;&#x660E;&#x4E86;&#x4E4B;&#x524D;&#x7684;&#x7ED3;&#x8BBA;&#x3002;</p>
<p>&#x603B;&#x7ED3;&#x5982;&#x4E0B;:</p>
<ul>
<li>DataProvider&#x7684;name&#x5C5E;&#x6027;&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x6307;&#x5B9A;&#x5219;&#x7528;&#x65B9;&#x6CD5;&#x540D;&#x79F0;&#x3002;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#x4E0D;&#x5EFA;&#x8BAE;&#x9ED8;&#x8BA4;&#x3002;<br>
&#x56E0;&#x4E3A;&#x6709;&#x65F6;&#x5019;&#x4F60;&#x53EF;&#x80FD;&#x91CD;&#x547D;&#x540D;&#x65B9;&#x6CD5;(&#x91CD;&#x6784;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6216;&#x8005;&#x590D;&#x5236;&#x591A;&#x4E2A;&#x7684;&#x65F6;&#x5019;&#x7B49;&#x7B49;)&#xFF0C;&#x5219;&#x4F1A;&#x5BFC;&#x81F4;&#x6D4B;&#x8BD5;&#x51FA;&#x9519;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x540D;&#x88AB;Test&#x6CE8;&#x89E3;&#x5F15;&#x7528;&#x8FC7;&#xFF0C;&#x9664;&#x975E;&#x6709;&#x7279;&#x6B8A;&#x7684;&#x5DE5;&#x5177;&#x652F;&#x6301;&#x6216;&#x8005;TestNg&#x672C;&#x8EAB;&#x652F;&#x6301;&#xFF0C;&#x91CD;&#x6784;&#x65B9;&#x6CD5;&#x4E0D;&#x4F1A;&#x91CD;&#x6784;Test&#x6CE8;&#x89E3;&#x4E2D;&#x7684;&#x8FD9;&#x4E2A;&#x540D;&#x79F0;&#xFF08;&#x5F53;&#x7136;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x5168;&#x5C40;&#x641C;&#x7D22;&#x66FF;&#x6362;&#xFF09;&#x3002;</li>
<li>&#x7531;&#x4E8E;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x662F;&#x6D4B;&#x8BD5;&#x7C7B;&#x7684;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x8BA9;&#x5B83;&#x5F52;&#x5C5E;&#x4E8E;&#x4E00;&#x4E2A;&#x8D85;&#x7C7B;&#xFF0C;&#x7136;&#x540E;&#x88AB;&#x4E00;&#x4E9B;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x590D;&#x7528;&#x3002;&#x6708;&#x53EF;&#x4EE5;&#x6709;&#x591A;&#x4E2A;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x65B9;&#x6CD5;&#xFF0C;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x53EA;&#x8981;&#x5B83;&#x4EEC;&#x5B9A;&#x4E49;&#x5728;&#x6D4B;&#x8BD5;&#x7C7B;&#x6216;&#x8005;&#x5176;&#x5B50;&#x7C7B;&#x4E0A;&#xFF0C;&#x6548;&#x679C;&#x4E5F;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;</li>
</ul>
<h3 class="mume-header" id="32-%E9%92%88%E5%AF%B9%E6%95%B0%E6%8D%AE%E6%8F%90%E4%BE%9B%E8%80%85%E7%9A%84%E5%8F%82%E6%95%B0">3.2 &#x9488;&#x5BF9;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x7684;&#x53C2;&#x6570;</h3>

<p>&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x65B9;&#x6CD5;&#x672C;&#x8EAB;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;Method&#x548C;ITestContext,&#x5728;&#x8C03;&#x7528;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x8BBE;&#x7F6E;&#x8FD9;&#x4E24;&#x4E2A;&#x53C2;&#x6570;,&#x5B83;&#x4EEC;&#x4E3A;&#x4EE3;&#x7801;&#x63D0;&#x4F9B;&#x4E86;&#x67D0;&#x79CD;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x7136;&#x540E;&#x5728;&#x6B64;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#x51B3;&#x5B9A;&#x518D;&#x505A;&#x4EC0;&#x4E48;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x9700;&#x8981;&#x4EFB;&#x610F;&#x8BBE;&#x7F6E;&#x8FD9;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x7EC4;&#x5408;&#x3002;</p>
<h4 class="mume-header" id="321-%E5%85%B3%E4%BA%8Emethod">3.2.1 &#x5173;&#x4E8E;Method</h4>

<p>&#x5148;&#x6765;&#x770B;&#x4E2A;&#x4F8B;&#x5B50;:</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParam&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParam</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@DataProvider</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParam&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">initTestUsersWithDataProviderParam</span><span class="token punctuation">(</span><span class="token class-name">Method</span> method<span class="token punctuation">,</span>
        <span class="token class-name">ITestContext</span> iTestContext<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;initTestUsersWithDataProviderParam&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x53C2;&#x6570;:{},&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:{}&quot;</span><span class="token punctuation">,</span>
            method<span class="token punctuation">,</span> iTestContext<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
            <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</pre><p>&#x4E0B;&#x9762;&#x662F;&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[2020.04.29 17:17:27] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersWithDataProviderParam&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x53C2;&#x6570;:public void com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProvider.validateUserTestWithProviderParam(java.lang.String,java.lang.String),&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:org.testng.TestRunner@80169cf
[2020.04.29 17:17:27] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:17:27] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:17:27] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:17:27] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin2,sex:women
[2020.04.29 17:17:27] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:17:27] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:women
PASSED: validateUserTestWithProviderParam(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderParam(&quot;admin2&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderParam(&quot;admin&quot;, &quot;women&quot;)

===============================================
    Default test
    Tests run: 3, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 3, Passes: 3, Failures: 0, Skips: 0
===============================================
</code></pre><p>&#x4ECE;&#x4E0A;&#x9762;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#x6765;&#xFF0C;&#x4F20;&#x8FDB;&#x6765;&#x7684;&#x53C2;&#x6570;Method&#x662F;&#x8C03;&#x7528;&#x4E86;&#x8FD9;&#x4E2A;dataProvider&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x54EA;&#x4E2A;&#x65B9;&#x6CD5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#xFF0C;&#x5219;<strong>&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x6765;&#x51B3;&#x5B9A;&#x662F;&#x5426;&#x9700;&#x8981;&#x533A;&#x522B;&#x5BF9;&#x5F85;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x3002;</strong></p>
<p><strong>&#x66F4;&#x6709;&#x751A;&#x8005;&#xFF0C;&#x53EF;&#x4EE5;&#x9488;&#x5BF9;&#x4E0D;&#x540C;&#x7684;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x6765;&#x8FD4;&#x56DE;&#x4E0D;&#x540C;&#x7684;&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x3002;</strong></p>
<p>&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF0C;&#x662F;&#x4E00;&#x4E2A;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x4E0D;&#x540C;&#x6D4B;&#x8BD5;&#x6570;&#x636E;&#x7684;&#xFF0C;&#x6309;&#x9700;&#x6539;&#x9020;&#x5373;&#x53EF;&#xFF0C;&#x5B9E;&#x9645;&#x573A;&#x666F;&#x4E2D;&#x4E0D;&#x4E00;&#x5B9A;&#x7ECF;&#x5E38;&#x6709;&#x8FD9;&#x79CD;&#x9700;&#x6C42;&#x3002;</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParamOfDiffTestMethod&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParamOne</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParamOfDiffTestMethod&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParamTwo</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParamOfDiffTestMethod&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParamDefault</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span>
        <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@DataProvider</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderParamOfDiffTestMethod&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">initTestUsersWithDataProviderParamOfDiffTestMethod</span><span class="token punctuation">(</span>
        <span class="token class-name">Method</span> method<span class="token punctuation">,</span> <span class="token class-name">ITestContext</span> iTestContext<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span>
            <span class="token string">&quot;initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x53C2;&#x6570;:{},&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:{}&quot;</span><span class="token punctuation">,</span>
            method<span class="token punctuation">,</span> iTestContext<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> resultObjects <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
            <span class="token punctuation">{</span> <span class="token string">&quot;admin2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>method<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">&quot;validateUserTestWithProviderParamOne&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        resultObjects <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
                <span class="token punctuation">{</span> <span class="token string">&quot;admin3&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin4&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>method<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">&quot;validateUserTestWithProviderParamTwo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        resultObjects <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
                <span class="token punctuation">{</span> <span class="token string">&quot;admin5&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin6&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> resultObjects<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</pre><p>&#x770B;&#x770B;&#x4E0B;&#x9762;&#x7684;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,
&#x4F20;&#x5165;&#x53C2;&#x6570;:public void com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProvider.validateUserTestWithProviderParamDefault(java.lang.String,java.lang.String),
&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:org.testng.TestRunner@80169cf
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin2,sex:women
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,
&#x4F20;&#x5165;&#x53C2;&#x6570;:public void com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProvider.validateUserTestWithProviderParamOne(java.lang.String,java.lang.String),
&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:org.testng.TestRunner@80169cf
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin3,sex:women
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin4,sex:women
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,
&#x4F20;&#x5165;&#x53C2;&#x6570;:public void com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProvider.validateUserTestWithProviderParamTwo(java.lang.String,java.lang.String),
&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;:org.testng.TestRunner@80169cf
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin,sex:man
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin5,sex:women
[2020.04.29 17:41:16] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.29 17:41:16] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProvider] name&#xFF1A;admin6,sex:women
PASSED: validateUserTestWithProviderParamDefault(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderParamDefault(&quot;admin2&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderParamOne(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderParamOne(&quot;admin3&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderParamOne(&quot;admin4&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderParamTwo(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderParamTwo(&quot;admin5&quot;, &quot;women&quot;)
PASSED: validateUserTestWithProviderParamTwo(&quot;admin6&quot;, &quot;women&quot;)

===============================================
    Default test
    Tests run: 8, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 8, Passes: 8, Failures: 0, Skips: 0
===============================================

</code></pre><h4 class="mume-header" id="322-%E5%85%B3%E4%BA%8Eitestcontext">3.2.2 &#x5173;&#x4E8E;ITestContext</h4>

<p>&#x5982;&#x679C;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x65B9;&#x6CD5;&#x4E2D;&#x4F20;&#x5165;&#x4E86;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48;TestNG&#x53EF;&#x4EE5;&#x628A;&#x8FD0;&#x884C;&#x65F6;&#x523B;&#x7684;&#x4E00;&#x4E9B;&#x4FE1;&#x606F;&#x8BBE;&#x7F6E;&#x7ED9;&#x5B83;&#xFF0C;&#x8FD9;&#x5C31;&#x53EF;&#x4EE5;&#x8BA9;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x77E5;&#x9053;&#x5F53;&#x524D;&#x6D4B;&#x8BD5;&#x6267;&#x884C;&#x7684;&#x8FD0;&#x884C;&#x65F6;&#x53C2;&#x6570;&#x3002;</p>
<p>&#x8FD8;&#x662F;&#x770B;&#x4E2A;&#x4F8B;&#x5B50;:</p>
<p>&#x5982;&#x4E0B;&#x662F;&#x4E00;&#x4E2A;&#x914D;&#x7F6E;&#x4E86;Test&#x548C;groups&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="xml" class="language-xml"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token doctype">&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>suite</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>DDT DATAPROIVIDER SUITE<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>test</span> <span class="token attr-name">thread-count</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>5<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>DDT DATAPROVIDER TEST<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>classes</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>class</span>
				<span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProviderITestContext<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>class</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>classes</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>test</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- Test --&gt;</span>

	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groups</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>run</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>testGroup1<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>include</span><span class="token punctuation">&gt;</span></span>
			<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>include</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>testGroup2<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>include</span><span class="token punctuation">&gt;</span></span>
		<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>run</span><span class="token punctuation">&gt;</span></span>
	<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groups</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>suite</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!-- Suite --&gt;</span>

</pre><p>&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;:</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,
&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:org.testng.TestRunner@b9afc07
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] 
&#x6D4B;&#x8BD5;&#x7EC4;:[testGroup2, testGroup1],suite:DDT DATAPROVIDER TEST
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin,sex:man
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin2,sex:women
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,
&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:org.testng.TestRunner@b9afc07
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] 
&#x6D4B;&#x8BD5;&#x7EC4;:[testGroup2, testGroup1],suite:DDT DATAPROVIDER TEST
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin,sex:man
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin3,sex:women
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin4,sex:women
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] initTestUsersWithDataProviderParamOfDiffTestMethod&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;
,&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:org.testng.TestRunner@b9afc07
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] 
&#x6D4B;&#x8BD5;&#x7EC4;:[testGroup2, testGroup1],suite:DDT DATAPROVIDER TEST
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin,sex:man
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin5,sex:women
[2020.04.29 18:03:20] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderITestContext] name&#xFF1A;admin6,sex:women

===============================================
DDT DATAPROIVIDER SUITE
Total tests run: 8, Passes: 0, Failures: 8, Skips: 0
===============================================

</code></pre><h3 class="mume-header" id="33-%E5%BB%B6%E8%BF%9F%E6%95%B0%E6%8D%AE%E6%8F%90%E4%BE%9B%E8%80%85">3.3 &#x5EF6;&#x8FDF;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;</h3>

<p>&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x672C;&#x8EAB;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#xFF0C;&#x8FD9;&#x662F;&#x901A;&#x5E38;&#x7684;&#x7528;&#x6CD5;&#x3002;&#x4F46;&#x6709;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x672A;&#x5FC5;&#x90FD;&#x4F1A;&#x76F4;&#x63A5;&#x4EE5;&#x660E;&#x786E;&#x7684;&#x65B9;&#x5F0F;&#x5B9A;&#x4E49;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x800C;&#x662F;&#x4ECE;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x67E5;&#x51FA;&#x6765;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x6709;&#x53EF;&#x80FD;&#x6709;&#x8FD9;&#x4E48;&#x4E00;&#x79CD;&#x573A;&#x666F;&#xFF0C;&#x4F60;&#x5B9A;&#x4E49;&#x4E86;&#x5F88;&#x591A;&#x6570;&#x636E;&#xFF0C;&#x653E;&#x5230;&#x4E86;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x4E2D;&#x6216;&#x8005;&#x67E5;&#x51FA;&#x6765;&#x4E0A;&#x5343;&#x4E07;&#x6761;&#x6570;&#x636E;&#x653E;&#x5230;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x4E2D;&#x3002;</p>
<p>&#x7531;&#x4E8E;&#x4FDD;&#x5B58;&#x7684;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E9B;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x4F1A;&#x5B58;&#x5728;&#x4E8E;&#x5185;&#x5B58;&#x4E2D;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x5C1D;&#x8BD5;&#x4E00;&#x4E0B;&#xFF0C;&#x4F1A;&#x5BFC;&#x81F4;&#x5185;&#x5B58;&#x6EA2;&#x51FA;&#xFF0C;&#x4E0D;&#x8FC7;&#x73B0;&#x5728;&#x7684;&#x5185;&#x5B58;&#x666E;&#x904D;&#x6BD4;&#x8F83;&#x5927;&#xFF0C;&#x8FD9;&#x4E2A;&#x6D4B;&#x8BD5;&#x6BD4;&#x8F83;&#x82DB;&#x523B;&#xFF08;&#x6709;&#x5174;&#x8DA3;&#x7684;&#x4E0D;&#x59A8;&#x8BD5;&#x4E00;&#x4E0B;&#xFF09;&#x3002;</p>
<p>&#x663E;&#x7136;&#x8FD9;&#x662F;&#x4E0D;&#x7406;&#x60F3;&#x7684;&#xFF0C;&#x90A3;&#x5C31;&#x6709;&#x4E00;&#x79CD;&#x65B9;&#x6848;&#x53EF;&#x4EE5;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x5C31;&#x662F;&#x5EF6;&#x8FDF;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x8FD9;&#x4E2A;&#x6982;&#x5FF5;&#x5E76;&#x4E0D;&#x65B0;&#x9896;&#xFF0C;&#x8F6F;&#x4EF6;&#x5DE5;&#x7A0B;&#x4E2D;&#x6709;&#x8BB8;&#x591A;&#x9886;&#x57DF;&#x90FD;&#x6709;&#x8FD9;&#x4E2A;&#x5E94;&#x7528;&#x3002;&#x5B83;&#x7684;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#x5C31;&#x662F;&#x5F53;&#x4F60;&#x771F;&#x6B63;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x518D;&#x521D;&#x59CB;&#x5316;&#x5B83;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x6EE1;&#x8DB3;&#x8FD9;&#x4E2A;&#x573A;&#x666F;&#xFF0C;TestNG&#x5141;&#x8BB8;&#x6211;&#x4EEC;&#x4ECE;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;Iterator&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x3002;</p>
<p>&#x5B83;&#x7684;&#x597D;&#x5904;&#x5C31;&#x5728;&#x4E8E;&#xFF0C;&#x5F53;TestNG&#x9700;&#x8981;&#x4ECE;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x53D6;&#x5F97;&#x4E0B;&#x4E00;&#x7EC4;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x8C03;&#x7528;iterator&#x7684;next&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x6700;&#x540E;&#x4E00;&#x523B;&#x521D;&#x59CB;&#x5316;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x521A;&#x597D;&#x5728;&#x9700;&#x8981;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x7684;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x8FD0;&#x884C;&#x4E4B;&#x524D;&#x3002;</p>
<p>&#x5982;&#x4E0B;&#x662F;&#x4EE3;&#x7801;&#x793A;&#x4F8B;:</p>
<pre data-role="codeBlock" data-info="java" class="language-java"><span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>lang<span class="token punctuation">.</span>reflect</span><span class="token punctuation">.</span><span class="token class-name">Method</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util</span><span class="token punctuation">.</span><span class="token class-name">Iterator</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">Logger</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>slf4j</span><span class="token punctuation">.</span><span class="token class-name">LoggerFactory</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng</span><span class="token punctuation">.</span><span class="token class-name">ITestContext</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">BeforeMethod</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">DataProvider</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>testng<span class="token punctuation">.</span>annotations</span><span class="token punctuation">.</span><span class="token class-name">Test</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>autotest<span class="token punctuation">.</span>java<span class="token punctuation">.</span>demo<span class="token punctuation">.</span>testng</span><span class="token punctuation">.</span><span class="token class-name">TestNGDemo</span><span class="token punctuation">;</span>

<span class="token comment">/**
 * @author : Administrator
 * @since : 2020&#x5E74;4&#x6708;29&#x65E5; &#x4E0B;&#x5348;2:37:04
 * @see :
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">TestNGDDTDemoTestWithDataProviderWithLazyInit</span> <span class="token punctuation">{</span>
	<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">Logger</span> LOGGER <span class="token operator">=</span> <span class="token class-name">LoggerFactory</span>
	        <span class="token punctuation">.</span><span class="token function">getLogger</span><span class="token punctuation">(</span><span class="token class-name">TestNGDDTDemoTestWithDataProviderWithLazyInit</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token keyword">private</span> <span class="token class-name">TestNGDemo</span> testNGDemo<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@BeforeMethod</span>
	<span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">initInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		testNGDemo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">TestNGDemo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithoutDataProviderOfLazyInit&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParamTwo</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
		testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@Test</span><span class="token punctuation">(</span>dataProvider <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderOfLazyInit&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">validateUserTestWithProviderParamDefault</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span>
	        <span class="token class-name">String</span> sex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;name&#xFF1A;{},sex:{}&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
		testNGDemo<span class="token punctuation">.</span><span class="token function">validateUser</span><span class="token punctuation">(</span>name<span class="token punctuation">,</span> sex<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@DataProvider</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithDataProviderOfLazyInit&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token class-name">Iterator</span> <span class="token function">initTestUsersWithDataProviderOfLazyInit</span><span class="token punctuation">(</span><span class="token class-name">Method</span> method<span class="token punctuation">,</span>
	        <span class="token class-name">ITestContext</span> iTestContext<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;initTestUsersWithDataProviderOfLazyInit&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:{}&quot;</span><span class="token punctuation">,</span>
		        iTestContext<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token class-name">Iterator</span> iterator <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DataInitIterator</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span><span class="token string">&quot;Iterator:{}&quot;</span><span class="token punctuation">,</span> iterator<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> iterator<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token annotation punctuation">@DataProvider</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;initTestUsersWithoutDataProviderOfLazyInit&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">public</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">initTestUsersWithoutDataProviderOfLazyInit</span><span class="token punctuation">(</span><span class="token class-name">Method</span> method<span class="token punctuation">,</span>
	        <span class="token class-name">ITestContext</span> iTestContext<span class="token punctuation">)</span> <span class="token punctuation">{</span>
		LOGGER<span class="token punctuation">.</span><span class="token function">debug</span><span class="token punctuation">(</span>
		        <span class="token string">&quot;initTestUsersWithoutDataProviderOfLazyInit&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:{}&quot;</span><span class="token punctuation">,</span>
		        iTestContext<span class="token punctuation">)</span><span class="token punctuation">;</span>

		<span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> resultObjects <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;man&quot;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
		        <span class="token punctuation">{</span> <span class="token string">&quot;admin2&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;women&quot;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

		<span class="token keyword">return</span> resultObjects<span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token keyword">class</span> <span class="token class-name">DataInitIterator</span> <span class="token keyword">implements</span> <span class="token class-name">Iterator</span> <span class="token punctuation">{</span>
		<span class="token keyword">static</span> <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> MAX <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">;</span>
		<span class="token keyword">private</span> <span class="token keyword">int</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

		<span class="token annotation punctuation">@Override</span>
		<span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">hasNext</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">return</span> index <span class="token operator">&lt;</span> MAX<span class="token punctuation">;</span>
		<span class="token punctuation">}</span>

		<span class="token annotation punctuation">@Override</span>
		<span class="token keyword">public</span> <span class="token class-name">Object</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">int</span> thisIndex <span class="token operator">=</span> index<span class="token operator">++</span><span class="token punctuation">;</span>
			<span class="token comment">// &#x6B64;&#x5904;&#x9700;&#x8981;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#xFF0C;&#x56E0;&#x4E3A;&#x6BCF;&#x4E2A;&#x4F4D;&#x7F6E;&#x662F;&#x6570;&#x7EC4;&#xFF0C;&#x624D;&#x80FD;&#x653E;&#x5728;&#x4E00;&#x8D77;&#x7EC4;&#x6210;&#x4E00;&#x4E2A;&#x8DDF;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x7B49;&#x6548;&#x7684;iterator</span>
			<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span> <span class="token string">&quot;admin&quot;</span> <span class="token operator">+</span> thisIndex<span class="token punctuation">,</span> <span class="token string">&quot;sex&quot;</span> <span class="token operator">+</span> thisIndex <span class="token punctuation">}</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>

		<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">remote</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">UnsupportedOperationException</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>

	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</pre><p>&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="txt" class="language-txt"><code>[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] initTestUsersWithDataProviderOfLazyInit&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:org.testng.TestRunner@382db087
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] Iterator:com.autotest.java.demo.testng.ddt.TestNGDDTDemoTestWithDataProviderWithLazyInit$DataInitIterator@43d7741f
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin0,sex:sex0
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin1,sex:sex1
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin2,sex:sex2
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin3,sex:sex3
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] initTestUsersWithoutDataProviderOfLazyInit&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x4F20;&#x5165;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;:org.testng.TestRunner@382db087
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin,sex:man
[2020.04.30 01:18:55] [INFO ] [c.a.j.d.t.TestNGDemo] com.autotest.java.demo.testng.TestNGDemo&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x88AB;&#x521D;&#x59CB;&#x5316;
[2020.04.30 01:18:55] [DEBUG] [c.a.j.d.t.d.TestNGDDTDemoTestWithDataProviderWithLazyInit] name&#xFF1A;admin2,sex:women
PASSED: validateUserTestWithProviderParamDefault(&quot;admin0&quot;, &quot;sex0&quot;)
PASSED: validateUserTestWithProviderParamDefault(&quot;admin1&quot;, &quot;sex1&quot;)
PASSED: validateUserTestWithProviderParamDefault(&quot;admin2&quot;, &quot;sex2&quot;)
PASSED: validateUserTestWithProviderParamDefault(&quot;admin3&quot;, &quot;sex3&quot;)
PASSED: validateUserTestWithProviderParamTwo(&quot;admin&quot;, &quot;man&quot;)
PASSED: validateUserTestWithProviderParamTwo(&quot;admin2&quot;, &quot;women&quot;)

===============================================
    Default test
    Tests run: 6, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 6, Passes: 6, Failures: 0, Skips: 0
===============================================

</code></pre><p>&#x5982;&#x6B64;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#xFF0C;&#x8FD4;&#x56DE;iterator&#x548C;&#x8FD4;&#x56DE;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x53EF;&#x4EE5;&#x7B49;&#x6548;&#x3002;<br>
&#x53C8;&#x56E0;&#x4E3A;&#x53EF;&#x4EE5;&#x5EF6;&#x8FDF;&#x5230;next&#x7684;&#x65F6;&#x5019;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x6240;&#x4EE5;&#x53EF;&#x4EE5;&#x505A;&#x5230;&#x5EF6;&#x8FDF;&#x521D;&#x59CB;&#x5316;&#x5BF9;&#x8C61;&#xFF0C;&#x65B9;&#x4FBF;&#x8FBE;&#x5230;&#x53EF;&#x4EE5;&#x8BA9;&#x4ED6;&#x4EEC;&#x4F7F;&#x7528;&#x5B8C;&#x5C31;&#x53EF;&#x4EE5;&#x88AB;&#x56DE;&#x6536;(&#x53EA;&#x662F;&#x88AB;&#x800C;&#x5DF2;&#xFF0C;&#x4E0D;&#x89C1;&#x5F97;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x56DE;&#x6536;)&#x3002;</p>
<h2 class="mume-header" id="%E5%9B%9B-%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F%E7%9A%84%E6%AF%94%E8%BE%83">&#x56DB;&#x3001;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x7684;&#x6BD4;&#x8F83;</h2>

<table>
<thead>
<tr>
<th>&#x65B9;&#x5F0F;</th>
<th>&#x4F18;&#x70B9;</th>
<th>&#x7F3A;&#x70B9;</th>
</tr>
</thead>
<tbody>
<tr>
<td>DataProvider</td>
<td>&#x53EF;&#x4EE5;&#x5411;&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x4EFB;&#x4F55;&#x6709;&#x6548;&#x7684;java&#x7C7B;&#x578B;;&#x975E;&#x5E38;&#x7075;&#x6D3B;;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;java&#x4EE3;&#x7801;&#x52A8;&#x6001;&#x7B97;&#x51FA;&#x6216;&#x4ECE;&#x5B58;&#x50A8;&#x673A;&#x5236;&#x91CC;&#x53D6;&#x51FA;&#x6765;</td>
<td>&#x5B9E;&#x73B0;&#x9700;&#x8981;&#x4E00;&#x4E9B;&#x903B;&#x8F91;&#xFF0C;&#x624D;&#x80FD; &#x8FD4;&#x56DE;&#x6B63;&#x786E;&#x7684;&#x5BF9;&#x8C61;</td>
</tr>
<tr>
<td>testng</td>
<td>&#x503C;&#x5728;xml&#x6587;&#x4EF6;&#x4E2D;&#x786E;&#x5B9A;&#xFF0C;&#x6613;&#x4E8E;&#x4FEE;&#x6539;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;; &#x503C;&#x901A;&#x8FC7;testNg&#x81EA;&#x52A8;&#x4F20;&#x9012;&#x7ED9;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x6574;&#x7406;&#x6216;&#x8F6C;&#x6362;</td>
<td>&#x9700;&#x8981;&#x4E00;&#x4E2A;xml&#x6587;&#x4EF6;&#xFF0C;&#x4E0D;&#x80FD;&#x52A8;&#x6001;&#x7B97;&#x503C;;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x503C;&#x53EA;&#x80FD;&#x4EE3;&#x8868;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#xFF0C;&#x4E0D;&#x80FD;&#x662F;&#x590D;&#x6742;&#x7684;&#x5BF9;&#x8C61;</td>
</tr>
</tbody>
</table>
<p>&#x603B;&#x4E4B;&#xFF0C;&#x7B80;&#x5355;&#x4F20;&#x9012;&#x5C31;&#x5229;&#x7528;xml&#x662F;&#x5F88;&#x597D;&#x7684;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x66F4;&#x591A;&#x7684;&#x7075;&#x6D3B;&#x6027;&#x5E76;&#x77E5;&#x9053;&#x53C2;&#x6570;&#x7684;&#x6570;&#x76EE;&#x548C;&#x503C;&#x5C06;&#x968F;&#x65F6;&#x95F4;&#x589E;&#x52A0;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5E94;&#x8BE5;&#x503E;&#x5411;&#x4E8E;DataProvider</p>
<h2 class="mume-header" id="%E4%BA%94-%E6%95%B0%E6%8D%AE%E7%9A%84%E6%8F%90%E4%BE%9B">&#x4E94;&#x3001; &#x6570;&#x636E;&#x7684;&#x63D0;&#x4F9B;</h2>

<p>DP&#x63D0;&#x4F9B;&#x6570;&#x636E;&#x7684;&#x65B9;&#x5F0F;&#x6709;&#x8BB8;&#x591A;&#x79CD;&#xFF0C;&#x4EE5;&#x4E0B;&#x5217;&#x4E3E;&#x4E86;&#x4E00;&#x4E9B;,&#x7B80;&#x5355;&#x8BF4;&#x4E0B;&#x4F18;&#x70B9;&#x548C;&#x4E0D;&#x8DB3;:</p>
<table>
<thead>
<tr>
<th>&#x6570;&#x636E;&#x4F4D;&#x7F6E;</th>
<th>&#x4F18;&#x70B9;</th>
<th>&#x7F3A;&#x70B9;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x786C;&#x7F16;&#x7801;&#x5728;Java&#x6E90;&#x7801;</td>
<td>&#x5F00;&#x53D1;&#x8005;&#x5F88;&#x6613;&#x4E8E;&#x4FEE;&#x6539;&#x548C;&#x89E3;&#x6790;</td>
<td>&#x4FEE;&#x6539;&#x89E6;&#x53D1;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#xFF1B;<br>&#x9664;&#x4E86;&#x5F00;&#x53D1;&#x8005;&#x4E4B;&#x5916;&#x5176;&#x4ED6;&#x4EBA;&#x63A5;&#x89E6;&#x3001;&#x7406;&#x89E3;&#x3001;&#x4FEE;&#x6539;&#x6BD4;&#x8F83;&#x96BE;</td>
</tr>
<tr>
<td>&#x6587;&#x672C;&#x4E2D;(&#x5982;&#x9017;&#x53F7;&#x5206;&#x9694;&#x7684;&#x503C;)</td>
<td>1. &#x5F00;&#x53D1;&#x8005;&#x60F3;&#x5BF9;&#x5BB9;&#x6613;&#x89E3;&#x6790;; <br> 2. &#x4E0D;&#x9700;&#x8981;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;(&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;&#x90FD;&#x6709;&#x8FD9;&#x79CD;&#x6709;&#x70B9;)&#x6613;&#x51FA;&#x9519;&#xFF0C;&#x6587;&#x672C;&#x6587;&#x4EF6;&#x5BB9;&#x6613;&#x7528;&#x4EFB;&#x4F55;&#x7F16;&#x8F91;&#x5668;&#x4FEE;&#x6539;&#xFF0C;&#x6BCF;&#x4E2A;&#x4EBA;&#x90FD;&#x6613;&#x4E8E;&#x4FEE;&#x6539;&#x70B9;&#x7ED3;&#x679C;&#x5C31;&#x662F;&#x5BB9;&#x6613;&#x51B2;&#x7A81;&#x548C;&#x53EF;&#x63A7;&#x6027;&#x8F83;&#x5DEE;&#xFF0C;&#x5F88;&#x5BB9;&#x6613;&#x7834;&#x574F;&#x683C;&#x5F0F;; <br> 3. &#x9700;&#x8981;&#x8BA9;&#x8BE5;&#x6587;&#x4EF6;&#x7684;&#x6301;&#x6709;&#x8005;&#x5171;&#x4EAB;&#x8BE5;&#x6587;&#x4EF6;&#xFF08;&#x4E0B;&#x9762;&#x7684;&#x51E0;&#x79CD;&#x9664;&#x4E86;&#x6570;&#x636E;&#x5E93;&#x4E4B;&#x5916;&#x90FD;&#x6709;&#x8FD9;&#x79CD;&#x9650;&#x5236;&#xFF09; <br>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;&#x6709;&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;: &#x5171;&#x4EAB;&#x7684;&#x7F51;&#x7EDC;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x3001;git&#x6216;&#x8005;svn&#x7B49;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7CFB;&#x7EDF;&#xFF0C;&#x4F46;&#x4F1A;&#x4EA7;&#x751F;&#x4E00;&#x5B9A;&#x7684;&#x98CE;&#x9669;&#x5BFC;&#x81F4;&#x6570;&#x636E;&#x4E22;&#x5931;&#x6216;&#x8005;&#x88AB;&#x76D7;&#x53D6;</td>
<td></td>
</tr>
<tr>
<td>&#x5C5E;&#x6027;&#x6587;&#x4EF6;&#x4E2D;</td>
<td>&#x5F00;&#x53D1;&#x8005;&#x53EF;&#x65B9;&#x4FBF;&#x5C06;&#x5176;&#x8F6C;&#x6362;&#x6210;java&#x7684;Properties&#x5BF9;&#x8C61;</td>
<td>&#x540C;&#x4E0A;&#xFF1B;  <br>&#x7ED3;&#x6784;&#x6709;&#x5C40;&#x9650;&#xFF1A;&#x53EA;&#x80FD;&#x4FDD;&#x5B58;&#x952E;&#x503C;&#x5BF9;&#xFF1B;&#x65E0;&#x5E8F;</td>
</tr>
<tr>
<td>Excel&#x4E2D;</td>
<td>&#x5F00;&#x53D1;&#x8005;&#x5BB9;&#x6613;&#x4F7F;&#x7528;&#x4E09;&#x65B9;&#x5E93;&#x89E3;&#x6790;&#xFF1B;&#x975E;&#x5F00;&#x53D1;&#x8005;&#x5BB9;&#x6613;&#x64CD;&#x4F5C;&#xFF1B; <br>&#x5BB9;&#x6613;&#x786E;&#x4FDD;&#x6570;&#x636E;&#x7684;&#x6B63;&#x786E;&#x6027;(&#x5B8F;&#x3001;&#x6216;&#x8005;&#x5176;&#x4ED6;&#x673A;&#x5236;&#x6765;&#x9A8C;&#x8BC1;)</td>
<td>&#x540C;&#x4E0A;;&#x9700;&#x8981;&#x5B89;&#x88C5;excel&#x624D;&#x80FD;&#x8BFB;&#x53D6;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x662F;&#x79C1;&#x6709;&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x683C;&#x5F0F;&#xFF0C;&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x8F6C;&#x4E3A;csv&#x7ED5;&#x8FC7;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x4F46;&#x76F8;&#x5BF9;&#x5C31;&#x4E22;&#x5931;&#x4E86;excel&#x7684;&#x4E00;&#x4E9B;&#x5143;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>DB&#x4E2D;</td>
<td>&#x9AD8;&#x5EA6;&#x7ED3;&#x6784;&#x5316;&#x800C;&#x4E14;&#x7075;&#x6D3B;; <br>&#x53EF;&#x4EE5;&#x4FDD;&#x5B58;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#x5E76;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x590D;&#x6742;&#x7684;sql&#x6765;&#x8BFB;&#x53D6;; <br>SQL&#x548C;JDBC&#x662F;JDK&#x672C;&#x8EAB;&#x81EA;&#x5E26;&#x7684;&#xFF0C;&#x6587;&#x6863;&#x6BD4;&#x8F83;&#x4E30;&#x5BCC;; <br>&#x53EF;&#x4EE5;&#x5C06;&#x6570;&#x636E;&#x5E93;&#x653E;&#x5230;&#x7F51;&#x7EDC;&#x4E0A;</td>
<td>&#x5BF9;&#x4E8E;&#x7A0B;&#x5E8F;&#x5458;&#x6765;&#x8BF4;&#xFF0C;&#x9700;&#x8981;&#x66F4;&#x52A0;&#x590D;&#x6742;&#x7684;&#x7A0B;&#x5E8F;&#x6765;&#x8BFB;&#x53D6;&#x548C;&#x89E3;&#x6790;&#xFF0C;&#x4F46;&#x53EF;&#x4EE5;&#x7528;&#x6846;&#x67B6;&#x6765;&#x51CF;&#x8F7B;&#x8D1F;&#x62C5;&#x5982;hibernate&#x548C;mybatis&#x3001;jpa&#x7B49;&#x7B49;; <br>&#x5411;&#x6570;&#x636E;&#x5E93;&#x63D2;&#x5165;&#x65B0;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x9700;&#x8981;&#x6709;&#x4E2A;&#x524D;&#x7AEF;&#x754C;&#x9762;&#xFF0C;&#x7279;&#x522B;&#x662F;&#x975E;&#x5F00;&#x53D1;&#x8005;&#x9700;&#x8981;&#x5F55;&#x5165;&#x7684;&#x65F6;&#x5019;;&#x6D4B;&#x8BD5;&#x9700;&#x8981;&#x989D;&#x5916;&#x7684;&#x5F00;&#x9500;&#xFF0C;&#x9700;&#x8981;&#x586B;&#x5145;&#x6570;&#x636E;&#x5230;&#x6570;&#x636E;&#x5E93;&#x624D;&#x80FD;&#x6D4B;&#x8BD5;</td>
</tr>
<tr>
<td>&#x7F51;&#x7EDC;&#x4E2D;</td>
<td>&#x62BD;&#x8C61;&#x5316;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x7684;&#x771F;&#x6B63;&#x65B9;&#x5F0F;;<br>&#x53EF;&#x4EE5;&#x6765;&#x6E90;&#x4E8E;&#x9694;&#x58C1;&#x7684;&#x8BA1;&#x7B97;&#x673A;&#x6216;&#x8005;&#x6A2A;&#x8DE8;&#x534A;&#x4E2A;&#x56FD;&#x5BB6;&#x548C;&#x5730;&#x7403;&#x800C;&#x6765;&#x81EA;&#x67D0;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x4E2D;&#x5FC3;l; <br>&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8BB8;&#x591A;&#x534F;&#x8BAE;&#x6BD4;&#x5982;tcp/ip&#x3001;jms&#x7B49;&#x7B49;</td>
<td>&#x9700;&#x8981;&#x590D;&#x6742;&#x7684;&#x7F16;&#x7A0B;&#x903B;&#x8F91;&#x4EE5;&#x53CA;&#x989D;&#x5916;&#x7684;&#x8BBE;&#x7F6E;&#x548C;&#x914D;&#x7F6E;</td>
</tr>
</tbody>
</table>
<h2 class="mume-header" id="%E5%85%AD-%E6%95%B0%E6%8D%AE%E6%8F%90%E4%BE%9B%E8%80%85%E8%BF%98%E6%98%AF%E5%B7%A5%E5%8E%82%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9">&#x516D;&#x3001;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x8FD8;&#x662F;&#x5DE5;&#x5382;&#xFF0C;&#x5982;&#x4F55;&#x9009;&#x62E9;&#xFF1F;</h2>

<p>&#x5728;&#x4E4B;&#x524D;&#x7684;&#x4E00;&#x7BC7;&#x6587;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x63D0;&#x5230;&#x4E86;&#x5DE5;&#x5382;&#xFF0C;&#x672C;&#x7BC7;&#x4E2D;&#x7740;&#x91CD;&#x63D0;&#x5230;&#x4E86;&#x6570;&#x636E;&#x9A71;&#x52A8;&#xFF0C;&#x90A3;&#x5B83;&#x4EEC;&#x90FD;&#x53EF;&#x4EE5;&#x5411;&#x6D4B;&#x8BD5;&#x63D0;&#x4F9B;&#x53C2;&#x6570;&#xFF1A;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x5411;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x53C2;&#x6570;&#xFF0C;&#x800C;&#x5DE5;&#x5382;&#x5411;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4F20;&#x9012;&#x53C2;&#x6570;&#x3002;<br>
&#x663E;&#x7136;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6570;&#x636E;&#x63D0;&#x4F9B;&#x8005;&#x7684;&#x5730;&#x65B9;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5DE5;&#x5382;&#xFF0C;&#x53CD;&#x4E4B;&#x4EA6;&#x7136;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4E0D;&#x786E;&#x5B9A;&#x600E;&#x4E48;&#x4F7F;&#x7528;&#xFF0C;&#x90A3;&#x5C31;&#x4ED4;&#x7EC6;&#x770B;&#x4E00;&#x4E0B;&#x5206;&#x6790;&#x4E00;&#x4E0B;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x3002;&#x662F;&#x4E0D;&#x662F;&#x6709;&#x51E0;&#x4E2A;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x9700;&#x8981;&#x540C;&#x6837;&#x7684;&#x53C2;&#x6570;&#xFF1F;&#x5982;&#x679C;&#x662F;&#xFF0C;&#x90A3;&#x5C31;&#x6700;&#x597D;&#x4FDD;&#x5B58;&#x5230;&#x4E00;&#x4E2A;&#x5B57;&#x6BB5;&#x4E2D;&#x7136;&#x540E;&#x5728;&#x51E0;&#x4E2A;&#x65B9;&#x6CD5;&#x4E2D;&#x590D;&#x7528;&#x5B57;&#x6BB5;&#xFF0C;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x9009;&#x62E9;&#x5DE5;&#x5382;&#x6BD4;&#x8F83;&#x5408;&#x9002;&#x3002;&#x53CD;&#x4E4B;&#xFF0C;&#x5982;&#x679C;&#x6240;&#x6709;&#x7684;&#x6D4B;&#x8BD5;&#x65B9;&#x6CD5;&#x90FD;&#x9700;&#x8981;&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48;DP&#x663E;&#x7136;&#x662F;&#x597D;&#x4E00;&#x4E9B;&#x3002;</p>
<p>&#x5F53;&#x7136;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4E24;&#x8005;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x3002;&#x8FD9;&#x4F1A;&#x6839;&#x636E;&#x5177;&#x4F53;&#x7684;&#x6D4B;&#x8BD5;&#x573A;&#x666F;&#x51B3;&#x5B9A;&#xFF0C;&#x6700;&#x7EC8;&#x8FD8;&#x662F;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x8005;&#x672C;&#x4EBA;&#x6765;&#x51B3;&#x5B9A;&#x3002;</p>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>